package com.taotao.manage.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.abel533.entity.Example;
import com.github.pagehelper.PageInfo;
import com.taotao.manage.pojo.Item;
import com.taotao.manage.pojo.ItemCat;
import com.taotao.manage.pojo.ItemParam;

@Service
public class ItemParamService extends BaseService<ItemParam> {
	
	@Autowired
	private ItemCatService itemCatService;
	
	public PageInfo<ItemParam> queryItemParamPageListByUpdate(Integer page, Integer rows) {
		//创建example对象
		Example example = new Example(Item.class);
		//根据时间进行倒叙查询数据
		example.setOrderByClause("updated DESC");
		PageInfo<ItemParam> pageInfo = super.queryPageListByExample(example, page, rows);
		List<ItemParam> list = pageInfo.getList();
		ItemCat itemCat = new ItemCat();
		for (int i = 0; i < list.size(); i++) {
			itemCat.setId(list.get(i).getItemCatId());
			String ItamCatName = itemCatService.queryOne(itemCat).getName();
			list.get(i).setItemCatName(ItamCatName);
		}
			return new PageInfo<ItemParam>(list);
	}

}
